cmake_minimum_required(VERSION 2.8)

project(Media)
message(STATUS "Project name : --- ${PROJECT_NAME}")

message(STATUS "Current dir : --- ${CMAKE_CURRENT_SOURCE_DIR}")

# CMAKE_BUILD_TYPE = Debug Release RelWithDebInfo MinSizeRel
# 固定设置为Debug，在本项目中最终发布的版本也是在Debug版本的集成上进行Strip。
# 详见HUNTER_RELEASE参数
set(CMAKE_BUILD_TYPE Release)

#-----------------------------------------------------------------------------
# 配置平台参数
#

if (NOT CROSS_PLATFORM)
	set(CROSS_PLATFORM RV1126)
endif ()

if (NOT UVC)
	set(UVC NO)
endif ()

if (NOT MODEL_NAME)
	set(MODEL_NAME ROOMS)
endif ()
if(MODEL_NAME STREQUAL "ROOMS")
	set(LIB_NAME Media_ROOMS)
	add_definitions(-DMODEL_ROOMS)
elseif(MODEL_NAME STREQUAL "TAIL")
	set(LIB_NAME Media_TAIL)
	add_definitions(-DMODEL_TAIL)
elseif(MODEL_NAME STREQUAL "AIR")
	set(LIB_NAME Media_AIR)
	add_definitions(-DMODEL_AIR)
else()
	set(LIB_NAME Media_ROOMS)
	add_definitions(-DMODEL_ROOMS)
endif()

message(STATUS "CROSS_PLATFORM : --- ${CROSS_PLATFORM}")
message(STATUS "MODEL_NAME :---${MODEL_NAME}")
message(STATUS "LIB_NAME :---${LIB_NAME}")
#-----------------------------------------------------------------------------

# 包含平台通用编译规则，为了那些跨平台代码，采用公共且唯一的allRules.cmake。
# 约定allRules.cmake，一般位于项目目录的向上三层目录内。
if (EXISTS ${PROJECT_SOURCE_DIR}/build/Rules/allRules.cmake)
	include(${PROJECT_SOURCE_DIR}/build/Rules/allRules.cmake)
else ()
	message(FATAL_ERROR "Can't include allRules.cmake")
endif ()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
if (${UVC} STREQUAL YES)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUVC")
endif()

add_subdirectory(src)
